|
|
|
|
|
|
|
If you want to create a series of bitmaps for later animation, you can use a much more sophisticated model. You could let your computer spend a few hours computing each frame in the animation. Later, you can play the frames back at the much faster rate of 10 or 20 frames per second, which is fast enough to produce smooth motion. |
|
|
|
|
|
|
|
|
Most objects do not emit light of their own. Instead, light from some other source falls on them. The object absorbs some of the light and reflects some of it. For instance, when you shine white light on a blue object, the object absorbs many of the green and red frequencies in the light and reflects most of the blue frequencies. Your eye detects the reflected blue frequencies, so you see the object as blue. |
|
|
|
|
|
|
|
|
A perfectly dull, matte surface reflects light equally in all directions. This sort of reflection is called diffuse reflection. A normal piece of paper is a reasonably matte surface. When you shine white light on a white piece of paper, the paper appears white no matter what your viewing angle. |
|
|
|
|
|
|
|
|
In reality, few surfaces are perfectly dull, so from some viewing angles you see highlights and other effects. If you place a piece of paper on a desk and move your eyes to different positions around the paper, you will see that the paper grows brighter and darker depending on the angle from which you are viewing it. Still, diffuse reflection plays a large role in determining the appearance of reasonably dull surfaces. |
|
|
|
|
|
|
|
|
For a perfect matte surface, the intensity of the diffuse reflected light from a point-sized light source is given by Lambert's law: |
|
|
|
 |
|
|
|
|
Id = Ii * kd * Cos(q) for 0 <= q <= p/2 |
|
|
|
|
|
|
|
|
Id is the resulting intensity of the diffuse reflected light. Since this value will be used with the RGB function to calculate a color, it must eventually lie between 0 and 255. |
|
|
|
|
|
|
|
|
II is the intensity of the incident light hitting the surface. Usually this is between 0 and 255, so Id is between 0 and 255. |
|
|
|
|
|
|
|
|
kd is a constant between 0.0 and 1.0 that represents the way the surface reacts to these wavelengths of light. The larger the value, the more light is reflected. |
|
|
|
|
|
|
|
|
q is the angle between the vector L pointing from the surface to the light source and the surface normal N. |
|
|
|
|
|
|
|
|
Figure 16.1 shows a light source shining on a surface with the angle q labeled. |
|
|
|
|
|
|
|
|
Suppose A and B are two vectors with components <xa, ya, za> and <xb, yb, zb>. Recall that the dot product of two vectors written A < B is defined as: |
|
|
|
 |
|
|
|
|
A B = xa * xb + ya * yb + za + zb |
|
|
|
|
|